<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>title</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/layoutnew.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/iconfont/iconfont.css"/>
    <style>
        html,body{
            background:rgba(0,0,0,0);
            background:url(../../images/bac.png) no-repeat;
            height: 100%;
        }


    </style>
</head>

<body ondblclick="closeFrame()">

<div class="aui-bar-nav-new" style="z-index: 99;position: fixed;top: 0">
    <div class="aui-pull-left" onclick="closeFrame();">
        <span class="icon iconfont icon-back">返回</span>
    </div>
    <span>任现职层次年限信息</span>

    <div class="aui-pull-right" style="color: transparent ">
        <span class="icon iconfont icon-back">占位</span>
    </div>
</div>


<div style="width: 100%;height: 99%;margin:0 auto;padding:3%;overflow: auto;">
    <div class="echartstwo">
        <div id="container-right-bottom" class="echartsfour" >

        </div>
    </div>

<!--表格-->
    <table border="0" class="table_rylb conytb">
        <tbody id="message-content">

        </tbody>
    </table>

</div>



<script id="message-content-template" type="text/x-dot-template">
        {{for(var i=0;i
        <it.length-1 ;i++){}}

        <tr class="bj">
            <td>{{=it[i][1]}}</td>

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}

            <td onclick="clickopenpeo('{{=it[i][0]}}','0','人员信息','{{=it[i][2]}}')">{{=it[i][2]}}
                {{? it[i][it[i].length-1][0] == '-' ||it[i][it[i].length-1][0] == '0.00'}}

                {{??}}
                </br>({{=it[i][it[i].length-1][0]}}%)
                {{?}}
            </td>
            {{?}}

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','1','人员信息','{{=it[i][3]}}')">{{=it[i][3]}}
                {{? it[i][it[i].length-1][1] == undefined ||it[i][it[i].length-1][1] == '0.00' }}
                {{??}}
                </br>({{=it[i][it[i].length-1][1]}}%)
                {{?}}
            </td>
            {{?}}

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','2','人员信息','{{=it[i][4]}}')">{{=it[i][4]}}
                {{? it[i][it[i].length-1][2] == undefined||it[i][it[i].length-1][2] == '0.00'}}
                {{??}}
                </br>({{=it[i][it[i].length-1][2]}}%)
                {{?}}
            </td>
            {{?}}

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','3','人员信息','{{=it[i][5]}}')">{{=it[i][5]}}
                {{? it[i][it[i].length-1][3] == undefined||it[i][it[i].length-1][3] == '0.00'}}
                {{??}}
                </br>({{=it[i][it[i].length-1][3]}}%)
                {{?}}
            </td>
            {{?}}

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','4','人员信息','{{=it[i][6]}}')">{{=it[i][6]}}
                {{? it[i][it[i].length-1][4] == undefined||it[i][it[i].length-1][4] == '0.00'}}
                {{??}}
                </br>({{=it[i][it[i].length-1][4]}}%)
                {{?}}
            </td>
            {{?}}

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','5','人员信息','{{=it[i][7]}}')">{{=it[i][7]}}
                {{? it[i][it[i].length-1][5] == undefined||it[i][it[i].length-1][5] == '0.00'}}
                {{??}}
                </br>({{=it[i][it[i].length-1][5]}}%)
                {{?}}
            </td>
            {{?}}

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','6','人员信息','{{=it[i][8]}}')">{{=it[i][8]}}
                {{? it[i][it[i].length-1][6] == undefined||it[i][it[i].length-1][6] == '0.00'}}
                {{??}}
                </br>({{=it[i][it[i].length-1][6]}}%)
                {{?}}
            </td>
            {{?}}

            {{? it[i].length<4}}
            <td>0</td>
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','7','人员信息','{{=it[i][9]}}')">{{=it[i][9]}}
                {{? it[i][it[i].length-1][7] == undefined||it[i][it[i].length-1][7] == '0.00'}}
                {{??}}
                </br>({{=it[i][it[i].length-1][7]}}%)
                {{?}}
            </td>
            {{?}}


            {{? it[0][10] == '-'||it[0][10] == null}}
            {{??}}
            <td onclick="clickopenpeo('{{=it[i][0]}}','8','人员信息','{{=it[i][10]}}')">{{=it[i][10]}}
                {{? it[i][it[i].length-1][8] == undefined||it[i][it[i].length-1][8] == '0.00'}}
                {{??}}
                </br>({{=it[i][it[i].length-1][8]}}%)
                {{?}}
            </td>
            {{?}}
        </tr>


        {{}}}
</script>




</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/scriptabxz.js"></script>
<script type="text/javascript" src="../../script/doT.min.js"></script>
<script type="text/javascript" src="../../script/leek-common.js"></script>
<script type="text/javascript" src="../../script/echarts.min.js"></script>
<script type="text/javascript">

  var   all_year_type
  var rowsidlist
  var place_code

  var role_zhengfu_name_array_again = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '副部', '正部']
  var role_jingcha_name_array_again = ['科员及其他', '三级警员', '二级警员', '一级警员', '四级警长', '三级警长', '二级警长', '一级警长']


  var role_zhengfu_name_array = ['-','科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '副部', '正部',' ']
  var role_jingcha_name_array = ['-','科员及其他', '三级警员', '二级警员', '一级警员', '四级警长', '三级警长', '二级警长', '一级警长',' ']
    apiready = function(){
        var   pageParam = api.pageParam.item;



        place_code = api.pageParam.item.place_code

        all_year_type = pageParam.all_year_type

        var namelist
        if(all_year_type == 'zhengfu'){
            namelist = role_zhengfu_name_array
            rowsidlist = ['16,17,18', '14,15', '13,12', '11,10', '9,8', '7,6', '5,4', '3', '2']

        }else {
            namelist = role_jingcha_name_array
            rowsidlist = ['28', '27', '26', '25', '24', '23', '22', '21']
        }

        showRightBottomChart(pageParam.containe_arr)



        var lt2 =pageParam.containe_arr.lt2.reverse()
        var gt2lt3 =pageParam.containe_arr.gt2lt3.reverse()
        var gt3lt4 =pageParam.containe_arr.gt3lt4.reverse()
        var gt4lt5 =pageParam.containe_arr.gt4lt5.reverse()
        var gt5lt6 =pageParam.containe_arr.gt5lt6.reverse()
        var gt6 =pageParam.containe_arr.gt6.reverse()



        pageParam.containe_arr.su1.push('不满2年')
        pageParam.containe_arr.su1.push('31')

        pageParam.containe_arr.su2.push('2年到不满3年')
        pageParam.containe_arr.su2.push('32')
        pageParam.containe_arr.su3.push('3年到不满4年')
        pageParam.containe_arr.su3.push('33')
        pageParam.containe_arr.su4.push('4年到不满五年')
        pageParam.containe_arr.su4.push('34')
        pageParam.containe_arr.su5.push('5年到不满6年')
        pageParam.containe_arr.su5.push('35')
        pageParam.containe_arr.su6.push('6年以上')
        pageParam.containe_arr.su6.push('36,37,38,39,40')




        var list_arr = []
        namelist.push(' ')

        list_arr[0] = namelist.reverse()

        list_arr[1]=pageParam.containe_arr.su1.reverse()
        list_arr[1].push(lt2)

        list_arr[2] =  pageParam.containe_arr.su2.reverse()
        list_arr[2].push(gt2lt3)

        list_arr[3] =  pageParam.containe_arr.su3.reverse()
        list_arr[3].push(gt3lt4)

        list_arr[4] =  pageParam.containe_arr.su4.reverse()
        list_arr[4].push(gt4lt5)


        list_arr[5] =  pageParam.containe_arr.su5.reverse()
        list_arr[5].push(gt5lt6)

        list_arr[6] =  pageParam.containe_arr.su6.reverse()
        list_arr[6].push(gt6)

        list_arr[7] =  rowsidlist.reverse()


        var interText = doT.template($("#message-content-template").text());
        $("#message-content").html(interText(list_arr));



        $(document).ready(function () {
            $("table").attr("bgColor", "#0c1a38");
           $("tr").attr("bgColor", "#3366CC");
          $("tr:even").css("background-color", "#0c1a38");

        });

        api.addEventListener({
            name: 'cleanarr'
        }, function (ret, err) {
            cleanarr()
        })


    };


    function showRightBottomChart(data) {


        if (data.lt2.length > 0 ) {


            var   onenumber = 0

            var role_zhengfu_name_array_again_1

            var role_zhengfu_name_array_again_2

            var role_zhengfu_name_array_again_3

            var role_zhengfu_name_array_again_4

            for (var key in data) {
                if (data[key][data[key].length - 1] == 0) {
                    onenumber++
                }
            }
            if (onenumber == 12) {
                role_zhengfu_name_array_again_1 = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '副部']
            }else {
                role_zhengfu_name_array_again_1 = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '副部', '正部']
            }
            var  twonumber = 0
            for (var key in data) {
                if (data[key][data[key].length - 2] == 0) {
                    twonumber++
                }
            }
            if (twonumber == 12) {
                role_zhengfu_name_array_again_2 = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '正部']
            }else {
                role_zhengfu_name_array_again_2 = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '副部', '正部']
            }


            var  threenumber = 0
            for (var key in data) {
                if (data[key][data[key].length - 3] == 0) {
                    threenumber++
                }
            }
            if (threenumber == 12) {
                role_zhengfu_name_array_again_3 = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '副部', '正部']
            }else {
                role_zhengfu_name_array_again_3 = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '副部', '正部']
            }


            var  frounumber = 0
            for (var key in data) {
                if (data[key][data[key].length - 4] == 0) {
                    frounumber++
                }
            }
            if (frounumber == 12) {
                role_zhengfu_name_array_again_4 = ['科员及其他', '副科', '正科', '副处', '正处', '正厅', '副部', '正部']
            }else {
                role_zhengfu_name_array_again_4 = ['科员及其他', '副科', '正科', '副处', '正处', '副厅', '正厅', '副部', '正部']
            }


            role_zhengfu_name_array_again = role_zhengfu_name_array_again_1.intersect(role_zhengfu_name_array_again_2).intersect(role_zhengfu_name_array_again_3).intersect(role_zhengfu_name_array_again_4)

        }






        var legend_array = ['不满2年', '2年至不满3年', '3年至不满4年', '4年至不满5年', '5年至不满6年', '6年及以上']

        right_bottom_chart = echarts.init(document.getElementById('container-right-bottom'))

        var param = data

        right_bottom_chart.showLoading({text: '正在努力的读取数据中...'})

        setOption = {
            color: ['#7F11C1', '#A820C6', '#C95AE4', '#0083C1', '#3270FF', '#0045DF'],
            tooltip: {
                trigger: 'axis',
                axisPointer: {
                    type: 'shadow'
                }
            },
            legend: {
                data: legend_array,
                itemGap: 3,
                textStyle: {
                    color: '#C1C1E4',
                    fontSize: 12
                },
                itemHeight: 12,
                itemWidth: 12
            },
            grid: {                   //边距
                top: 40,    //距离容器上边界40像素
                bottom: 10,   //距离容器下边界30像素
                left: 10,
                right: 15,
                containLabel: true
            },
            xAxis: {
                type: 'value',
                axisLine: {
                    lineStyle: {
                        color: '#0087ED',
                        width: 1
                    }
                },

                min: 0,
                max: 100,
                axisLabel: {
                    interval: 'auto',
                    formatter: '{value}%',
                    fontSize: 12// 让字体变大
                },
                splitLine: {
                    show: false
                },
                axisTick: {
                    show: true,
                    length: 3,
                    lineStyle: {
                        opacity: 0.5
                    }
                },
                show: true
            },
            yAxis: {
                type: 'category',
                data: all_year_type == 'zhengfu' ? role_zhengfu_name_array_again : role_jingcha_name_array_again,
                axisLine: {
                    lineStyle: {
                        color: '#0087ED',
                        width: 1
                    }
                },
                axisTick: {
                    show: true,
                    length: 3,
                    lineStyle: {
                        opacity: 0.5
                    }
                },
                splitLine: {
                    show: false
                },
                axisLabel: {
                    interval: 0,
                    rotate: 0,   //字体倾斜角度
                    fontSize: 12// 让字体变大
                }
            },
            series: [
                {
                    name: legend_array[0],
                    type: 'bar',
                    stack: '总量',
                    barWidth: 12,
                    label: {
                        normal: {
                            position: 'insideRight'
                        }
                    },
                    data: param.lt2
                },
                {
                    name: legend_array[1],
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            position: 'insideRight'
                        }
                    },
                    data: param.gt2lt3
                },
                {
                    name: legend_array[2],
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            position: 'insideRight'
                        }
                    },
                    data: param.gt3lt4
                },
                {
                    name: legend_array[3],
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            position: 'insideRight'
                        }
                    },
                    data: param.gt4lt5
                },
                {
                    name: legend_array[4],
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            position: 'insideRight'
                        }
                    },
                    data: param.gt5lt6
                },
                {
                    name: legend_array[5],
                    type: 'bar',
                    stack: '总量',
                    label: {
                        normal: {
                            position: 'insideRight'
                        }
                    },
                    data: param.gt6
                }
            ]
        }

        right_bottom_chart.setOption(setOption)

        right_bottom_chart.hideLoading()
    }



  var rossidlist = []

  var colsidlist = []

  var peosqllist = []


  var sqlthree = null

  var colrowidnumber

  var number


  var sqlwhereone


  function clickopenpeo(colsid, numb, name, val, ID) {

      colrowidnumber = 0
      number = 0

     var rowsid = rowsidlist[numb]


      rossidlist = rowsid.split(",");

      colsidlist = colsid.split(",");

      colrowidnumber = parseInt(rossidlist.length)*parseInt(colsidlist.length)

      var sql_arr = []

      var re = /^[0-9]+.?[0-9]*$/

      if (val != 0 && re.test(val)) {
          for (i = 0; i < rossidlist.length; i++) {
              for (a = 0; a < colsidlist.length; a++) {
                  selectSql(converFcrySql(colsidlist[a], rossidlist[i]), function (ret, err) {
                      var sql = ret.data[0].DRILLSQL;
                      var newsql = sql.replace(/\"/g, "'");
                      var sqlone = newsql.substring(newsql.lastIndexOf("@FIELDS@") + 9, newsql.lastIndexOf("AND"));

                      var pjsqlone = sqlone.substring(0, sqlone.lastIndexOf("AND") + 3);
                      //   pjsqltwo = newsql.substring(newsql.lastIndexOf(")") + 1, newsql.lastIndexOf(","));

                      sqlwhereone = newsql.substring(newsql.lastIndexOf("@FIELDS@") + 9, newsql.lastIndexOf("WHERE") + 6);

                      var sqlwhere = sqlone.substring(sqlone.lastIndexOf("WHERE") + 6,sqlone.lastIndexOf("AND"));

                      sql_arr.push(sqlwhere)

                      number++
                      if(number == colrowidnumber ){

                          var comsql = ''
                          for (i = 0; i < sql_arr.length; i++) {
                              comsql += "(" + sql_arr[i] + ") OR "

                          }
                          comsql ="("+ comsql.substr(0, comsql.length - 3)+") and"

                          if (judgeIsAnyNullStr(ID)) {
                              sqlthree = "select RS_A01.ID ID, A0101, (CASE WHEN A0104 = 1 THEN '男'else'女'end) A0104, age, a0140, (SELECT NAME FROM DIC_RS_GB3304 WHERE CODE = A0117) A0117, A0192, (SELECT NAME FROM DIC_rs_Zb09 where code = A0172) A0172 " + sqlwhereone + comsql + " (RS_A01.NID like '" + place_code + "%') " +  "order by rs_a01.aorder "
                          } else {
                              sqlthree = "select RS_A01.ID ID, A0101, (CASE WHEN A0104 = 1 THEN '男'else'女'end) A0104, age, a0140, (SELECT NAME FROM DIC_RS_GB3304 WHERE CODE = A0117) A0117, A0192, (SELECT NAME FROM DIC_rs_Zb09 where code = A0172) A0172 " + sqlwhereone + comsql + " (RS_A01.NID like '" + ID + "%') " + "order by rs_a01.aorder "

                          }

                          var item = {
                              sql: sqlthree,
                              name: name
                          }
                          comOpenWin('dwpeolist_win', '../dwlist/', item, 2);


                      }

                  })
              }
          }

      }
  }



  function cleanarr() {
      peosqllist = []
      sqlthree = null
  }

  function converFcrySql(colsid, rowsid) {
      var sql = "SELECT * FROM GWY_RPT_LD_NODESQL WHERE  ROWSID='" + rowsid + "' AND COLSID='" + colsid + "' AND RPTABLEID='JT2017001';"
      return sql
  }

</script>
</html>